import {http} from '@/utils'
import type {ResType} from './shared'

// 2.定义具体的接口类型
export type ChannelItem = {
    id: number
    name: string
}

// 3.接口请求
type ChannelRes = {
    channels: ChannelItem[]
}

// 4. 组合
export function fetchChannelAPI() {
    return http.request<ResType<ChannelRes>>({
        url: '/channels',
    })
}

// 请求文章列表
type ListItem = {
    art_id: string
    title: string
    out_id: string
    comm_count: string
    pubdate: string
    aut_name: string
    is_top:number
    cover:{
        type:number
        images:string[]
    }
}

export type ListRes  = {
    results: ListItem[]
    pre_timestamp: string
}

type ReqParams = {
    channel_id: string
    timestamp: string
}


export function fetchListAPI(params:ReqParams) {
    return http.request<ResType<ListRes>>({
        url: '/articles',
        params
    })
}
